﻿<Table TItem="BindItem" IsPagination="true" PageItemsSource="@PageItemsSource"
       IsStriped="true" IsBordered="true"
       ShowToolbar="true" ShowDefaultButtons="false"
       OnQueryAsync="@OnQueryAsync">
    <TableColumns>
        <TableColumn @bind-Field="@context.DateTime" Width="180" />
        <TableColumn @bind-Field="@context.Name" Width="100" />
        <TableColumn @bind-Field="@context.Address" />
        <TableColumn @bind-Field="@context.Count" />
    </TableColumns>
    <DetailRowTemplate>
        <Tab>
            <TabItem Text="明细数据">
                @{
                // 此段代码为提高性能
                var cacheKey = context.Name ?? "";
                var DetailDataSource = Enumerable.Empty<DetailRow>
                    ();
                    if (Cache.ContainsKey(cacheKey))
                    {
                    DetailDataSource = Cache[cacheKey];
                    }
                    else
                    {
                    DetailDataSource = GetDetailRowsByName(cacheKey).ToList();
                    Cache.Add(cacheKey, DetailDataSource);
                    }
                    }
                    <Table TItem="DetailRow" IsBordered="true" ShowToolbar="false" Items="@DetailDataSource">
                        <TableColumns Context="Detail">
                            <TableColumn @bind-Field="@Detail.Name" />
                            <TableColumn @bind-Field="@Detail.DateTime" Width="180" />
                            <TableColumn @bind-Field="@context.Complete" Width="70">
                                <Template Context="v">
                                    <Switch IsDisabled="true" Value="v.Value" ShowInnerText="true" OnInnerText="是" OffInnerText="否" />
                                </Template>
                            </TableColumn>
                        </TableColumns>
                    </Table>
            </TabItem>
            <TabItem Text="关联数据">
                <div>学历: @typeof(EnumEducation).ToDescriptionString(context.Education.ToString())</div>
            </TabItem>
        </Tab>
    </DetailRowTemplate>
</Table>
